package com.zw.yzk.kabu.view.activity.imagedetails;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.zw.yzk.kabu.R;


public class ImageDetailsActivity extends BaseImageDetailsActivity {

    private ImageView defaultBg;
    protected ImageView image;

    public static void startDetailsActivity(Context from, String picUrl, Rect fromRect) {
        if (TextUtils.isEmpty(picUrl)) {
            return;
        }
        Intent intent = new Intent(from, ImageDetailsActivity.class);
        intent.putExtra("url", picUrl);
        intent.putExtra("fromRect", fromRect);
        from.startActivity(intent);
        //禁用过渡动画
        if (from instanceof Activity) {
            ((Activity) from).overridePendingTransition(0, 0);
        }
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        defaultBg = (ImageView) findViewById(R.id.default_bg);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_image;
    }

    @Override
    protected String getEnterImageUrl() {
        return getIntent().getStringExtra("url");
    }

    @Override
    protected Rect getStartRect() {
        return getIntent().getParcelableExtra("fromRect");
    }

    @Override
    protected ImageView getAnimatedImageView() {
        if (image == null) {
            image = (ImageView) findViewById(R.id.details);
        }
        return image;
    }

    @Override
    protected void onAnimatedEnd() {
        defaultBg.setVisibility(View.GONE);
    }
}

